package com.xbang.attendance.entity.system;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.xbang.attendance.entity.product.Product;

/**
 * @author huawei
 * @email alonelaval@gmail.com
 */

public class AddProductLog implements Serializable{
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Integer id;

	/** 产品 */
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, targetEntity = Product.class)
	@JoinColumn(columnDefinition = "product", referencedColumnName = "id")
	private Product product;

	/** 仓库 */
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, targetEntity = Warehouse.class)
	@JoinColumn(columnDefinition = "warehouse", referencedColumnName = "id")
	private Warehouse warehouse;

	/** 产品数量 */
	private BigDecimal amount;
	
	
	//@Column(name = "") 
	/**加货或减货*/
	@Column(name = "minus_or_plus")
	@org.hibernate.annotations.Type(type = "yes_no")
	private boolean minusOrPlus = false;
	
	private Date date;
	/***
	 * 是否是虚拟的
	 */
	@Column(name = "virtual")
	@org.hibernate.annotations.Type(type = "yes_no")
	private boolean virtual;
	
	
	public AddProductLog(){
		
	}
	public void initial(Warehouse warehouse, Product product, BigDecimal amount,Boolean isVirtual) {
		this.amount = amount;
		this.warehouse = warehouse;
		this.product = product;
		this.date = new Date();
		this.virtual = virtual;
		if(amount.doubleValue() < 0){
			this.minusOrPlus = false;
		}
		else {
			this.minusOrPlus = true;
		}
	}
	
	public boolean isVirtual() {
		return virtual;
	}
	public void setVirtual(boolean virtual) {
		this.virtual = virtual;
	}
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Warehouse getWarehouse() {
		return warehouse;
	}

	public void setWarehouse(Warehouse warehouse) {
		this.warehouse = warehouse;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public boolean isMinusOrPlus() {
		return minusOrPlus;
	}

	public void setMinusOrPlus(boolean minusOrPlus) {
		this.minusOrPlus = minusOrPlus;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}
	
}

